#include <QStyleFactory>
#include <QApplication>
#include <QMainWindow>
#include <QTextCodec>
#include <QFont>
#include <QDebug>
#include "assembly/MainView.hpp"
#include "store/type/MetaMoldType.hpp"
#include "store/type/ActionWrapper.hpp"
#include "store/struct/LadderLine.hpp"
#include "store/struct/LadderLineCarrier.hpp"
#include "store/struct/DurationCarrier.hpp"
#include "store/struct/Synthetic.hpp"
#include "store/struct/MergeToAll.hpp"
#include "store/struct/Reference.hpp"
#include "store/struct/Source.hpp"
#include "store/struct/Basic.hpp"
#include "tool/Tool.hpp" // 包含 Tool.hpp

int main(int argc, char *argv[]) {
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication app(argc, argv);

    // 设置应用程序的样式和字体
    QApplication::setStyle(QStyleFactory::create("Fusion"));
    QApplication::setFont(QFont("Segoe UI", 12));
    QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));


    qRegisterMetaType<MetaMoldType::MoldType>("MetaMoldType::MoldType");
    qRegisterMetaType<ActionWrapper::ActionType>("ActionWrapper::ActionType");
    qRegisterMetaType<ActionWrapper::StateKey>("ActionWrapper::StateKey");

    qRegisterMetaType<LadderLineCarrier>("PointTrigger");
    qRegisterMetaType<LadderLineCarrier>("LadderLineCarrier");
    qRegisterMetaType<LadderLine>("LadderLine");
    qRegisterMetaType<Synthetic>("DurationCarrier");
    qRegisterMetaType<Synthetic>("Synthetic");
    qRegisterMetaType<Reference>("MergeToAll");
    qRegisterMetaType<Reference>("Reference");
    qRegisterMetaType<Source>("Source");
    qRegisterMetaType<Basic>("Basic");
    qRegisterMetaType<Rhythm>("Rhythm");


    // 使用 Tool::analysisParser 解析命令行参数并获取路径
    QString importAnalysisPath = Tool::analysisParser(app);

    // 初始化并显示主视图
    MainView mainView;
    mainView.setWindowTitle("节拍管理");
    mainView.resize(1600, 880);
    mainView.show();

    return app.exec();
}
